/-boot
BootLayout.ts
boot.ts
/-docs
/-editor
CodeMirrorEditor.ts
CompletionCodeMirrorEditor.ts
CssEditorType.ts
Editor.ts
EditorType.ts
HtmlEditorType.ts
JavaScriptEditorType.ts
TypeScriptEditorType.ts
x-last-PlainTextEditorType.ts
/-files
/-files-old
/-imports
/-layout
/-storage ...
/-storage/attached ...
/-storage/attached/api
/-storage/attached/dom ...
DetectStorage.ts
LoadStorage.ts
UpdateStorage.ts
/-storage/attached/indexedDB
/-storage/attached/localStorage
/-storage/attached/webSQL
/-tests
/-typings
TypeScriptService.ts
functions.ts
ko.ts
nteapo.html
persistence.api.ts
persistence.ts
shell.ts
teapo.html
teapo.ts
xxxxxxxxxx
 
1
module teapo.storage.attached.dom {
2
3
  export class LoadStorage implements attached.LoadStorage {
4
5
    editedUTC: number;
6
7
    private _byName: { [fullPath: string]: HTMLElement; } = {};
8
    private _sizesByName: { [fullPath: string]: { [property: string]: number; }; } = {};
9
10
    constructor(
11
      private _parentElement: HTMLElement,
12
      private _document: { createElement(tag: string): HTMLElement; }) {
13
14
      // populate editedUTC from corresponding attribute
15
      var editedUTCValue = this._parentElement.getAttribute('data-edited-utc');
16
      if (editedUTCValue) {
17
        try {
18
          this.editedUTC = parseInt(editedUTCValue);
19
        }
20
        catch (parseEditedUTCError) {
21
          console.log('parsing editedUTC ' + parseEditedUTCError);
22
        }
23
      }
24
    }
25
26
    load(recipient: LoadStorageRecipient): void {
27
      var dbg = {};
28
      this._loadFromElement(this._parentElement, recipient, dbg);
29
      //console.log('load() editedUTC: ' + this.editedUTC, dbg, this._parentElement);
30
      var updater = new UpdateStorage(this._parentElement, this._byName, this._document);
31
      recipient.completed(updater);
32
    }
33
34
    migrate(
35
      editedUTC: number,
36
      filesByName: { [fullPath: string]: { [propertyName: string]: string; }; },
37
      callback: (error: Error, updater: attached.UpdateStorage) => void): void {
38
39
      this._wipeExistingElement();
40
      if (editedUTC)
41
        this._parentElement.setAttribute('data-edited-utc', editedUTC + '');
42
      this.editedUTC = editedUTC;
43
      //console.log('migrate(' + editedUTC + ', ' , filesByName, this._parentElement);
44
45
46
      if (filesByName) {
47
        for (var fullPath in filesByName) if (filesByName.hasOwnProperty(fullPath)) {
48
          var element = UpdateStorage.createElement(this._parentElement, fullPath, this._document);
49
          var pbag = filesByName[fullPath];
50
          for (var pname in pbag) if (pbag.hasOwnProperty(pname)) {
51
            UpdateStorage.updateProperty(element, pname, pbag[pname]);
52
          }
53
          this._byName[fullPath] = element;
54
        }
55
      }
56
57
      var updater = new UpdateStorage(this._parentElement, this._byName, this._document);
58
7:78